<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <!--如果没登录显示该元素-->
    <a v-show="!isLogin" href="#" @click="login()">登录</a>
    <!--如果登录了显示该元素-->
    <a v-show="isLogin" href="#" @click="logout()">登出</a>
    <span  v-show="isLogin">
        <input type="text" v-model="name">
        <input type="button" value="添加" @click="addfn()">
    </span>
    <hr>
    <ul>
        <li v-for="name in arr">{{name}}</li>
    </ul>
</div>
<script src="vue.js"></script>
<script>
    let v=new Vue({
        el:"div",
        data:{
            isLogin:false,
            arr:["刘备","关羽","张飞"],
            name:""
        },
        methods:{
            login:function () {
                v.isLogin=true;
            },
            logout:function () {
                if (confirm("您确认退出登录吗?")){
                    v.isLogin=false;
                }
            },
            addfn:function () {
                /*把用户输入的名字添加到数组中*/
                v.arr.push(v.name);
            }

        }
    })
</script>

</body>
</html>